package com.atguigu.gmall.user.controller;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.common.util.AuthContextHolder;
import com.atguigu.gmall.model.user.UserAddress;
import com.atguigu.gmall.user.service.UserAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author atguigu-mqx
 * @Description TODO
 * @Date 2023/5/23 14:42
 * @Version 1.0
 */
@RestController
@RequestMapping("/api/user/userAddress")
public class UserApiContrller {

    @Autowired
    private UserAddressService userAddressService;

    //  查询收货地址列表：为了与h5端url 路径一致。

    /**
     * 获取用户地址
     * @param request
     * @return
     */
    @GetMapping("/auth/findUserAddressList")
    public Result findUserAddressListByUserId(HttpServletRequest request){
        //  获取用户Id
        String userId = AuthContextHolder.getUserId(request);
        //  查询收货地址列表
        return Result.ok(userAddressService.findUserAddressListByUserId(userId));
    }
}
